package com.care.doctor.remote.factory;

import com.care.common.core.domain.Result;
import com.care.doctor.common.domain.DTODoctor;
import com.care.doctor.common.req.GetDoctorReq;
import com.care.doctor.remote.DoctorRemoteService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author: 靳家振
 * @Date: 2024/3/27 19:08
 * @Description:
 **/

@Component
public class RemoteDoctorServiceFallback implements FallbackFactory<DoctorRemoteService> {
    public final static Logger logger = org.slf4j.LoggerFactory.getLogger(RemoteDoctorServiceFallback.class);
    @Override
    public DoctorRemoteService create(Throwable cause) {
        logger.error ("远程调用失败：{}", cause.getMessage ());
        return new DoctorRemoteService () {
            @Override
            public Result<PageInfo<DTODoctor>> findDoctor(GetDoctorReq req) {
                return Result.error ("医师列表繁忙，请稍后再试");
            }
        };
    }
}
